package com.xbao.dao;

import com.xbao.model.Cls;
import com.xbao.model.ClsExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface ClsMapper {
    @SelectProvider(type=ClsSqlProvider.class, method="countByExample")
    int countByExample(ClsExample example);

    @DeleteProvider(type=ClsSqlProvider.class, method="deleteByExample")
    int deleteByExample(ClsExample example);

    @Delete({
        "delete from cls",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into cls (name, status, ",
        "maxstus, eid, comments, ",
        "createtime, updatetime, ",
        "orgid, sid, type, ",
        "isdel, rid)",
        "values (#{name,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
        "#{maxstus,jdbcType=BIGINT}, #{eid,jdbcType=BIGINT}, #{comments,jdbcType=VARCHAR}, ",
        "#{createtime,jdbcType=BIGINT}, #{updatetime,jdbcType=BIGINT}, ",
        "#{orgid,jdbcType=BIGINT}, #{sid,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, ",
        "#{isdel,jdbcType=INTEGER}, #{rid,jdbcType=BIGINT})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(Cls record);

    @InsertProvider(type=ClsSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(Cls record);

    @SelectProvider(type=ClsSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="maxstus", property="maxstus", jdbcType=JdbcType.BIGINT),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="sid", property="sid", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="isdel", property="isdel", jdbcType=JdbcType.INTEGER),
        @Result(column="rid", property="rid", jdbcType=JdbcType.BIGINT)
    })
    List<Cls> selectByExample(ClsExample example);

    @Select({
        "select",
        "id, name, status, maxstus, eid, comments, createtime, updatetime, orgid, sid, ",
        "type, isdel, rid",
        "from cls",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="maxstus", property="maxstus", jdbcType=JdbcType.BIGINT),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="sid", property="sid", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="isdel", property="isdel", jdbcType=JdbcType.INTEGER),
        @Result(column="rid", property="rid", jdbcType=JdbcType.BIGINT)
    })
    Cls selectByPrimaryKey(Long id);

    @UpdateProvider(type=ClsSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Cls record, @Param("example") ClsExample example);

    @UpdateProvider(type=ClsSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Cls record, @Param("example") ClsExample example);

    @UpdateProvider(type=ClsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Cls record);

    @Update({
        "update cls",
        "set name = #{name,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "maxstus = #{maxstus,jdbcType=BIGINT},",
          "eid = #{eid,jdbcType=BIGINT},",
          "comments = #{comments,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=BIGINT},",
          "updatetime = #{updatetime,jdbcType=BIGINT},",
          "orgid = #{orgid,jdbcType=BIGINT},",
          "sid = #{sid,jdbcType=BIGINT},",
          "type = #{type,jdbcType=INTEGER},",
          "isdel = #{isdel,jdbcType=INTEGER},",
          "rid = #{rid,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Cls record);
}